<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <father></father>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Child = {
      template:`
        <div>
          <h2>子组件</h2>
          {{ a }}
          {{ b }}
          {{ c }}
          {{ d }}
          {{ e }}
        </div>
      `,
      // properties
      props:{
        a: String,
        b: [String, Number],
        c: {
          type: Number,
          required: true
        },
        d: {
          type: String,
          default: '默认值'
        },
        e: {
          type: Array,
          default: () => [1,2,3,4]
        }
      }
    }
    const Father = {
      template: `
        <div>
          <h1>这是父组件</h1>        
          <child a="a" :b="10" :c="10"></child>
          
        </div>
        
      `,
      data(){
        return {
          msg: '组件父内部数据'
        }
      },
      methods: {
        changeMsg(){
          this.msg = '值改变了';
        }
      },
      components: {
        Child
      }
    };
    Vue.component('Father', Father)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>